package com.zjq.designpatterns.behaviors.interpreter.code;/*
 * 版权信息: 北京千⾥马网信科技有限公司</br>
 * Copyright ©2008-2018. All rights reserved. 京ICP备16007318号
 */

/**
 * @author jessie
 * @version 1.0
 * @date 2021/1/27
 */
public class OperatorUtil {
    public static boolean isOperator(String symbol){
        return (symbol.equals("+") || symbol.equals("*"));
    }

    public static Interpreter getExpressionObject(Interpreter firstExpression, Interpreter secondExpression, String symbol){
        if (symbol.equals("+")) {
            return new AddInterpreter(firstExpression, secondExpression);
        }else if(symbol.equals("*")){
            return new MultiInterpreter(firstExpression, secondExpression);
        }
        return null;
    }
}
